package com.vm.activity;

import com.wwtscapp.apk.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

@SuppressLint("InflateParams")
public class SignSuccessDialog {
	private static Dialog signDialog;

	public static void showDialogForLoading(Activity context,
			boolean cancelable, String intergral) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.sign_in_success_dialog, null);
		ImageView imageView2 = (ImageView) view.findViewById(R.id.imageView2);
		TextView add_record = (TextView) view.findViewById(R.id.add_record);
		add_record.setText("积分+"+intergral);
		RotateAnimation anim = new RotateAnimation(20f, 50f,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f);
		anim.setInterpolator(new LinearInterpolator());
		anim.setRepeatCount(Animation.INFINITE);
		anim.setDuration(700);
		imageView2.startAnimation(anim);
		Animation animation = AnimationUtils.loadAnimation(context,
				R.anim.sign_success);
		add_record.startAnimation(animation);
		signDialog = new Dialog(context, R.style.loading_dialog_style);
		signDialog.setCancelable(cancelable);
		signDialog.setContentView(view, new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.MATCH_PARENT));
		signDialog.show();
	}

	public static void hideDialog() {
		if (signDialog != null && signDialog.isShowing()) {
			signDialog.cancel();
		}
	}
}